<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
</head>
<body>
<img id="lun" src="../../img/banner_1.jpg" width="100%">
<script>

    //1.获取图片对象
    //定义方法，修改图片路径1-2-3-1-2-3-1
    var number = 1;

    function fun() {
        number++;
        var lun = document.getElementById("lun");
        if (number > 3) {
            number = 1;
        }
        //循环路径
        lun.src = "../../img/banner_" + number + ".jpg";
    }

    //使用循环定时器，每隔2秒切换图片的路径
    setInterval(fun, 2000);
</script>
</body>
</html>